﻿using System.Linq;
using PTop.Application.Biz;
using System.Web.Mvc;
using PTop.Code;

namespace PTop.Web.Controllers
{
    [HandlerLogin]
    public class HomeController : Controller
    {
        [HttpGet]
        public ActionResult Index()
        {
            return View();
        }
        [HttpGet]
        public ActionResult Default()
        {
            return View();
        }

        [HttpPost]
        [HandlerAjaxOnly]
        public ActionResult GetTodayUserStatisticsJson()
        {
            var userStatisticsApp = new UserStatisticsApp();
            var userStatistics = userStatisticsApp.GetFormToday();
            return Content(new AjaxResult { state = ResultType.success.ToString(), data = userStatistics }.ToJson());
        }

        [HttpPost]
        [HandlerAjaxOnly]
        public ActionResult GetUserStatisticsJson()
        {
            var userStatisticsApp = new UserStatisticsApp();
            var userStatistics = userStatisticsApp.GetListForHome().OrderBy(m => m.F_Date).ToArray();
            return Content(new AjaxResult { state = ResultType.success.ToString(), data = userStatistics }.ToJson());
        }

        [HttpGet]
        public ActionResult About()
        {
            return View();
        }
    }
}
